#include "lvgl_project.h"
static lv_obj_t* time_label = NULL;
static void desktop_event_cb(lv_event_t* e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t* cont = lv_event_get_target(e);
    printf("getsure");
}

void lvgl_main_init()
{

    lv_obj_t* bg = lv_layer_top();
    time_label = lv_label_create(bg);
    lv_obj_align(time_label, LV_ALIGN_TOP_MID, 0, 0);
    lv_label_set_text(time_label,"time");

    //根节点点，所有的page都以这个lv_obj_t为parent，各自独立
    lv_page_manager_create(lv_scr_act());

    //根节点 根据root节点创建page
    lv_page_create(MAIN_PAGE, lv_desktop_create,NULL, lv_desktop_entry_ani, lv_desktop_exit_ani);
    lv_page_create(WEATHER_PAGE, lv_weather_page_create, NULL, lv_desktop_entry_ani, lv_desktop_exit_ani);
    lv_page_create(START_PAGE, start_page, NULL, boot_ainmation, NULL);

    //首次必须先加载main_page,调用所有的构造函数
    lv_main_page_start_up();
    lv_page_load(START_PAGE);
}

void time_get()
{
    struct time_info time;
    char hour[3];
    char min[3];
    char *text = (char *)malloc(8);
    while (!msg_manager_deque(3, &time))
    {
        //进制度转换
        itoa(time.hour, hour,10);
        itoa(time.minute, min,10);
        sprintf(text,"%s:%s",hour,min);
        printf("text = %s\n",text);
        lv_label_set_text(time_label,text);
    }

}

